﻿using System;

namespace Malu.WebTemplates
{
    public class BaseNormalPage : System.Web.UI.Page
    {
        public BaseNormalPage()
        {
            //
            // TODO: Add constructor logic here
            //
        }


        #region List部分属性

        public Pager Pager
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).Pager;
                }
                return null;
            }
        }

        public bool ShowPager
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowPager;
                }
                return false;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowPager = value;
                }
            }
        }

        public Order Order
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).Order;
                }
                return null;
            }
        }

        public string DefaultLayout
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).DefaultLayout;
                }
                return null;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).DefaultLayout = value;
                }
            }
        }

        public bool ShowLRLayoutButton
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowLRLayoutButton;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowLRLayoutButton = value;
                }
            }
        }

        public bool ShowUDLayoutButton
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowUDLayoutButton;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowUDLayoutButton = value;
                }
            }
        }

        public bool ShowSimpleLayoutButton
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowSimpleLayoutButton;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowSimpleLayoutButton = value;
                }
            }
        }

        public bool ShowAdvancedSearch
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowAdvancedSearch;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowAdvancedSearch = value;
                }
            }
        }

        public bool ShowScrollDiv
        {
            get
            {
                if (this.Master is ListMaster)
                {
                    return (this.Master as ListMaster).ShowScrollDiv;
                }
                return true;
            }
            set
            {
                if (this.Master is ListMaster)
                {
                    (this.Master as ListMaster).ShowScrollDiv = value;
                }
            }
        }
        #endregion

        #region Detail部分属性

        public bool UseTabber
        {
            get
            {
                if (this.Master is DetailMaster)
                {
                    return (this.Master as DetailMaster).UseTabber;
                }
                return true;
            }
            set
            {
                if (this.Master is DetailMaster)
                {
                    (this.Master as DetailMaster).UseTabber = value;
                }
            }
        }
        #endregion

        protected override void OnInit(EventArgs e)
        {
            if (this.Pager != null)
                this.Pager.PageChanged += new PageChangeEventHandler(Pager_PageChanged);

            if (this.Order != null)
                this.Order.OrderChanged += new OrderChangeEventHandler(Order_OrderChanged);

            base.OnInit(e);
        }

        protected virtual void Order_OrderChanged(object sender, EventArgs e)
        {
        }

        protected virtual void Pager_PageChanged(object sender, EventArgs e)
        {
        }

    }
}